<?php
namespace App\Common\Lib\Fun;

use App\Common as com;

class Class_ {

	/**
	 * 获取类名（不包含命名空间）
	 * @param  string|object $class
	 * @return string
	 */
	public static function getClassBasename( $class ):string {
		$class = is_object( $class ) ? get_class( $class ) : $class;
		return basename( str_replace( '\\', '/', $class ) );
	}

	/**
	 * 返回类中匹配前缀的方法名组成的数组
	 * @param string $prefix 前缀
	 * @return array
	 */
	public static function getClassMethodsOfMatchPrefix( $classThis, string $prefix ) {
		$classMethods = get_class_methods( $classThis );
		$clientMethods = [];
		$prefixLength = strlen( $prefix );
		foreach( $classMethods as $classMethodsValue ){
			if( substr( $classMethodsValue, 0, $prefixLength ) === $prefix ){
				$clientMethods[] = $classMethodsValue;
			}
		}
		//
		return $clientMethods;
	}

}
